﻿using IceCS.EMS.DAL;
using IceCS.EMS.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IceCS.EMS.BLL
{
    public class DbManager
    {
        /// <summary>
        /// 
        /// </summary>
        public void InitDB()
        {
            try
            {
                DBHelper.GetConnection();
                Console.WriteLine("数据库连接成功！");
            }
            catch (Exception ex)
            {
                Console.WriteLine("数据库连接错误！");
                throw ex;
            }
            AppInfo.CurrentUser = AppInfo.Admin;
            var currDIr = Environment.CurrentDirectory;
            var path = Path.Combine(currDIr, "init.flg");
            if (File.Exists(path))
            {
                return;
            }
            File.Create(path);

            var manager = new EmployeeManager();
            manager.SaveAdd(AppInfo.Admin);
        }
    }
}
